﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using HA.ModFlow.Controls;

namespace HA.ModFlow.Application
{
   public static class RecentDocumentVM
    {

         private static object _lockObject = new object();
        private static Dictionary<string, ControlData> _dataCollection = new Dictionary<string, ControlData>();

        public static ControlData RecentDocuments
        {
            get
            {
                lock (_lockObject)
                {
                    string Str = "最近打开项目：";

                    if (!_dataCollection.ContainsKey(Str))
                    {


                        GalleryCategoryData<RecentProjectData> galleryCategoryData = new GalleryCategoryData<RecentProjectData>();

                        if (ConfigService.DefaultService.SettingInfo!=null)
                        {

                            int index = 1;

                            for (int i = ConfigService.DefaultService.SettingInfo.RecentFile.Count - 1; i > ConfigService.DefaultService.SettingInfo.RecentFile.Count - 7 && i >= 0; i--)
                            {
                                History h = ConfigService.DefaultService.SettingInfo.RecentFile[i];

                                RecentProjectData recentProjectData = new RecentProjectData()
                                {
                                    Index = index,
                                    ToolTipDescription=h.FilePath,
                                    Command = AppCommands.OpenProjectWithName,
                                    Label = "  "+index.ToString ()+"  "+ h.ProjName
                                    //LargeImage = new Uri("/HA.ModFlow.Application;component/Images/main.png", UriKind.RelativeOrAbsolute),

                                    //ToolTipTitle=h.FilePath,
                                    //ToolTipDescription=h.FilePath

                                };


                                galleryCategoryData.GalleryItemDataCollection.Add(recentProjectData);

                                index++;

                            }
                            
                        }


                      
                        




                        _dataCollection[Str] = galleryCategoryData;

                    }

                    return _dataCollection[Str];
                }
            }
        }
    }


    
}
